<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>3.事件修饰符</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../../js/vue.js"></script>
    <style>
      .box{
        background-color: skyblue;
        border-radius: 10px;
        padding: 10px;
        box-shadow: 0 0 10px;
      }
    </style>
  </head>
  <body>
    <!-- 准备好一个容器-->
    <div id="demo">
      <!-- prevent修饰符，作用：阻止默认行为 -->
      <form action="https://www.baidu.com">
        <button @click.prevent="showLog1">点我</button>
      </form>
      <hr>
      <!-- stop修饰符，作用：阻止冒泡 -->
      <div @click="showLog2" class="box">
        <button @click.stop="showLog2">点我</button>
      </div>
      <hr>
      <!-- once修饰符，作用： -->
      <button @click.once="showLog3">点我</button>
      <hr>
      <!-- 修饰符可以串联 -->
      <div @click="showLog4">
        <a @click.prevent.stop="showLog4" href="https://www.baidu.com">点我</a>
      </div>
    </div>

    <script type="text/javascript">
      new Vue({
        el:'#demo',
        methods:{
          showLog1(e){
            console.log(1)
          },
          showLog2(e){
            console.log(2)
          },
          showLog3(e){
            console.log(3)
          },
          showLog4(e){
            console.log(4)
          }
        }
      })
    </script>
  </body>
</html>